package com.library.weiget;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.Button;

import com.jtjrenren.android.taxi.driver.R;

/**
 * Created by Administrator on 2016/3/14.
 */
public class CustomeGetImgDialog extends Dialog implements View.OnClickListener {
    public interface GetImgListener{
        void getFromCamera();
        void getFromImgs();
    }

    private Button bt_pz, bt_imgs, bt_cancle;

    private GetImgListener listener;

    public void setListener(GetImgListener listener) {
        this.listener = listener;
    }

    public CustomeGetImgDialog(Context context) {
        super(context);
        initView(context);
    }

    public CustomeGetImgDialog(Context context, int themeResId) {
        super(context, themeResId);
        initView(context);
    }

    protected CustomeGetImgDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
        initView(context);
    }

    private void initView(Context context) {
        View view = View.inflate(context,
                R.layout.dlg_custome_getimg, null);

        bt_pz = (Button) view.findViewById(R.id.dlg_getimg_pz);
        bt_imgs = (Button) view.findViewById(R.id.dlg_getimg_imgs);
        bt_cancle = (Button) view.findViewById(R.id.dlg_getimg_cancle);


        bt_pz.setOnClickListener(this);
        bt_cancle.setOnClickListener(this);
        bt_imgs.setOnClickListener(this);

        setContentView(view);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.dlg_getimg_cancle:
                dismiss();
                break;
            case R.id.dlg_getimg_pz:
                dismiss();
                if (listener!=null)
                    listener.getFromCamera();
                break;
            case R.id.dlg_getimg_imgs:
                dismiss();
                if (listener!=null)
                    listener.getFromImgs();
                break;
        }
    }
}
